#include <stdio.h>
#include <stdlib.h>

char map[4][4];

int check(char c)
{
    int i, j;

    for (i = 0; i < 4; i++) {
        for (j = 0; j < 4; j++) {
            if (map[i][j] != c && map[i][j] != 'T') {
                break;
            }
            if (j == 3) {
                return 1;
            }
        }
    }

    for (j = 0; j < 4; j++) {
        for (i = 0; i < 4; i++) {
            if (map[i][j] != c && map[i][j] != 'T') {
                break;
            }
            if (i == 3) {
                return 1;
            }
        }
    }

    for (i = 0; i < 4; i++) {
        if (map[i][i] != c && map[i][i] != 'T') {
            break;
        }
        if (i == 3) {
            return 1;
        }
    }

    for (i = 0; i < 4; i++) {
        if (map[i][3-i] != c && map[i][3-i] != 'T') {
            break;
        }
        if (i == 3) {
            return 1;
        }
    }
    
    return 0;
}

int main (int argc, char const* argv[])
{
    int n, i, j, cnt, drawflg;

    scanf("%d", &n); getchar();
    cnt = 1;
    while (cnt <= n) {
        drawflg = 1;
        for (i = 0; i < 4; i++) {
            for (j = 0; j < 4; j++) {
                map[i][j] = getchar();
                if (map[i][j] == '.') drawflg = 0;
            }
            getchar();
        }
        getchar();

        printf("Case #%d: ", cnt);
        if (check('O')) {
            printf("O won\n");
        } else if (check('X')) {
            printf("X won\n");
        } else if (drawflg) {
            printf("Draw\n");
        } else {
            printf("Game has not completed\n");
        }

        cnt++;
    }

    return 0;
}
